package com.lottery.im.module.chat.presenter;

import android.app.Activity;
import com.lottery.im.base.BaseFragmentPresenter;
import com.lottery.im.module.chat.view.InviteGroupMemberView;
import com.tencent.imsdk.TIMGroupMemberInfo;
import com.tencent.imsdk.TIMValueCallBack;
import com.tencent.imsdk.ext.group.TIMGroupManagerExt;
import com.trello.rxlifecycle2.LifecycleProvider;
import com.trello.rxlifecycle2.android.FragmentEvent;
import java.util.List;

public class InviteGroupMemberPresenter extends BaseFragmentPresenter<InviteGroupMemberView> {

  public InviteGroupMemberPresenter(Activity activity,
      InviteGroupMemberView iView,
      LifecycleProvider<FragmentEvent> provider) {
    super(activity, iView, provider);
  }

  /**
   * 获取群成员（主要是拿到ID，防止邀请已经入群到好友再次入群）
   *
   * @param dentify 群ID
   */
  public void getGroupMembers(String dentify) {
    TIMGroupManagerExt.getInstance().getGroupMembers(dentify,
        new TIMValueCallBack<List<TIMGroupMemberInfo>>() {
          @Override public void onError(int i, String s) {
          }

          @Override public void onSuccess(List<TIMGroupMemberInfo> timGroupMemberInfos) {
            if (null == iView) return;
            iView.showMemberInfo(timGroupMemberInfos);
          }
        });
  }
}
